﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Shove.Web.UI;

public partial class UserControls_Flash : UCBase
{
    public UserControls_Flash()
    {
        Name = "Flash控件";

        swpas = new ShoveWebPartAttribute[14];

        swpas[0] = new ShoveWebPartAttribute_Int("控件的宽度", "1,1000", 550, "控件的宽度");
        swpas[1] = new ShoveWebPartAttribute_Int("图片的宽度", "1,1000", 547, "图片的宽度");
        swpas[2] = new ShoveWebPartAttribute_Int("图片的高度", "1,1000", 200, "图片的高度");

        swpas[3] = new ShoveWebPartAttribute_Image("显示的图片1", "", "", "显示的图片1");
        swpas[4] = new ShoveWebPartAttribute_Image("显示的图片2", "", "", "显示的图片2");
        swpas[5] = new ShoveWebPartAttribute_Image("显示的图片3", "", "", "显示的图片3");
        swpas[6] = new ShoveWebPartAttribute_Image("显示的图片4", "", "", "显示的图片4");
        swpas[7] = new ShoveWebPartAttribute_Image("显示的图片5", "", "", "显示的图片5");
        swpas[8] = new ShoveWebPartAttribute_Image("显示的图片6", "", "", "显示的图片6");
        swpas[9] = new ShoveWebPartAttribute_Image("显示的图片7", "", "", "显示的图片7");
        swpas[10] = new ShoveWebPartAttribute_Image("显示的图片8", "", "", "显示的图片8");

        swpas[11] = new ShoveWebPartAttribute_PageNavigate("图片的默认连接页面", "Default.aspx", "图片的默认连接页面");

        swpas[12] = new ShoveWebPartAttribute_Text("控件的CSS样式", "", "full", "控件的CSS样式");

        swpas[13] = new ShoveWebPartAttribute_Int("图片切换时间", "1,60", 5, "图片切换时间");   
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        InitLayOut();
    }

    private void InitLayOut()
    {
        tabctr.Width = swpAttributes[0];
        ShoveImagePlayer1.imgWidth = Shove._Convert.StrToInt(swpAttributes[1], 300);
        ShoveImagePlayer1.imgHeight = Shove._Convert.StrToInt(swpAttributes[2], 200);

        ShoveImagePlayer1.CssClass = swpAttributes[12];
        ShoveImagePlayer1.TimeOut = Shove._Convert.StrToInt(swpAttributes[13], 5);

        string[] Strs = new string[6];
        string[] Links = new string[6];

        try
        {
            Strs[0] = "images/flash_banner/" + new DAL.Tables.tbl_Site_TemplatesFile().Open("", "[ID] = 1", "").Rows[0]["FileName"].ToString();
            Strs[1] = "images/flash_banner/" + new DAL.Tables.tbl_Site_TemplatesFile().Open("", "[ID] = 2", "").Rows[0]["FileName"].ToString();
            Strs[2] = "images/flash_banner/" + new DAL.Tables.tbl_Site_TemplatesFile().Open("", "[ID] = 3", "").Rows[0]["FileName"].ToString();
            Strs[3] = "images/flash_banner/" + new DAL.Tables.tbl_Site_TemplatesFile().Open("", "[ID] = 4", "").Rows[0]["FileName"].ToString();
            Strs[4] = "images/flash_banner/" + new DAL.Tables.tbl_Site_TemplatesFile().Open("", "[ID] = 5", "").Rows[0]["FileName"].ToString();
            Strs[5] = "images/flash_banner/" + new DAL.Tables.tbl_Site_TemplatesFile().Open("", "[ID] = 6", "").Rows[0]["FileName"].ToString();


            Links[0] = new DAL.Tables.tbl_Site_TemplatesFile().Open("", "[ID] = 1", "").Rows[0]["Links"].ToString();
            Links[1] = new DAL.Tables.tbl_Site_TemplatesFile().Open("", "[ID] = 2", "").Rows[0]["Links"].ToString();
            Links[2] = new DAL.Tables.tbl_Site_TemplatesFile().Open("", "[ID] = 3", "").Rows[0]["Links"].ToString();
            Links[3] = new DAL.Tables.tbl_Site_TemplatesFile().Open("", "[ID] = 4", "").Rows[0]["Links"].ToString();
            Links[4] = new DAL.Tables.tbl_Site_TemplatesFile().Open("", "[ID] = 5", "").Rows[0]["Links"].ToString();
            Links[5] = new DAL.Tables.tbl_Site_TemplatesFile().Open("", "[ID] = 6", "").Rows[0]["Links"].ToString();
    
        }
        catch { }
   
        string str = "";
        string lstr = "";
        string tstr = "";
        for (int i = 3; i <= 8; i++)
        {
            if (Strs[i-3] != "")
            {
                if (i == 8)
                {
                    str += Strs[i - 3] ;
                    lstr += Links[i - 3] ;
                    tstr += (i - 3).ToString();
                }
                else
                {
                    str += Strs[i - 3] + "|";
                    lstr += Links[i - 3] + "|";
                    tstr += (i - 3).ToString() + "|";
                }
            }
        }
        if (str == "")
        {
            ShoveImagePlayer1.Pics = "";
            ShoveImagePlayer1.Titles = "";
            ShoveImagePlayer1.Links = "";
        }
        else
        {
            ShoveImagePlayer1.Pics = Shove._String.Cut(str, str.Length - 1);
            ShoveImagePlayer1.Links = Shove._String.Cut(lstr, str.Length - 1);
            ShoveImagePlayer1.Titles = Shove._String.Cut(tstr, str.Length - 1);
        }
    }
}
